var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({
    extended: false
}));
app.use(cookieParser("xzx"));
app.use("/admin", express.static(path.join(__dirname, './public/admin'))); //通过/admin访问后台
app.use("/www", express.static(path.join(__dirname, './public/www'))); //通过/admin访问后台
app.use("/upload",  express.static(path.join(__dirname, './public/upload')));
app.use("/", express.static(path.join(__dirname, './public/www'))); //通过/访问前台
app.use(require("./permission"));
//在这里注册路由
//作者:向志祥
app.use("/api/MovieAndCinema", require("./routes/MovieAndCinema"));
//作者：段彦蓉
app.use("/api/upload", require("./routes/upload"));
//作者：段彦蓉
app.use("/api/Cinema", require("./routes/Cinema"));
//作者：徐凡
app.use("/api/movie", require("./routes/movie")); //电影路由
app.use("/api/movieupload", require("./routes/movieupload")); //图片上传

//注册了一个登陆的路由
//作者：唐源江
app.use("/api/user", require("./routes/user"));

// //作者：徐凡 读取数据
// const saveMovie=require("./DataGenerator/movie")
// saveMovie();
// //作者：徐凡 读取数据
// const saveMovie=require("./DataGenerator/cinema.js")
// saveMovie();

// 作者：洪刚
// 文章路由
app.use("/api/Article", require("./routes/Article"));
app.use("/articleUpload",require("./routes/articleUpload"));

module.exports = app;